//
//  CTShowCall.m
//  CT
//
//  Created by liufanwei on 15/4/7.
//  Copyright (c) 2015年 liufanwei. All rights reserved.
//

#import "CTShowCall.h"
#import "CTUserDefaultHelper.h"

@interface CTShowCall()
{
    BOOL showNumber;
}
@property (weak, nonatomic) IBOutlet UIButton *BTNCancel;
@property (weak, nonatomic) IBOutlet UIButton *BTNP;
@property (weak, nonatomic) IBOutlet UIButton *BTNShow;

@property (weak, nonatomic) IBOutlet UIButton *BTNCommit;
@end


@implementation CTShowCall

-(void)awakeFromNib{
    [super awakeFromNib];
    _SmallBG.layer.cornerRadius = 4;
    _SmallBG.layer.masksToBounds = YES;
    _SmallBG.layer.borderWidth = 1;
    [self setIsAutoRemove:NO];
    showNumber = [[CTUserDefaultHelper ShareInstance] ShowNumber];
    [self updateUI];
}

- (IBAction)protectedMy:(id)sender {
    showNumber = NO;
    [self updateUI];
}

- (IBAction)showCallNumber:(id)sender {
    showNumber = YES;
    [self updateUI];
}

-(void)updateUI{
    NSString * checkName = @"cheked";
    NSString * uncheckName = @"checkbackground";
    if (showNumber) {
        [_BTNP setImage:[UIImage imageNamed:uncheckName] forState:UIControlStateNormal];
        [_BTNP setImage:[UIImage imageNamed:uncheckName] forState:UIControlStateSelected];
        [_BTNShow setImage:[UIImage imageNamed:checkName] forState:UIControlStateNormal];
        [_BTNShow setImage:[UIImage imageNamed:checkName] forState:UIControlStateSelected];
    }else{
        [_BTNP setImage:[UIImage imageNamed:checkName] forState:UIControlStateNormal];
        [_BTNP setImage:[UIImage imageNamed:checkName] forState:UIControlStateSelected];
        [_BTNShow setImage:[UIImage imageNamed:uncheckName] forState:UIControlStateNormal];
        [_BTNShow setImage:[UIImage imageNamed:uncheckName] forState:UIControlStateSelected];
    }
}

- (IBAction)Cancel:(id)sender {
    [self removeFromSuperview];
}

- (IBAction)Commit:(id)sender {
   [[CTUserDefaultHelper ShareInstance] setShowNumber:showNumber];
    [self removeFromSuperview];
}

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
